OstreeRepoCheckoutMode mode,
OstreeRepoCheckoutOverwriteMode overwrite_mode,
GFile *source,
- GFile *destination,
int dirfd,
+ const char *name,
gboolean *out_was_supported,
GCancellable *cancellable,
GError **error)
gboolean ret_was_supported = FALSE;
again:
- if (dirfd != -1 &&
- linkat (-1, gs_file_get_path_cached (source),
- dirfd, gs_file_get_basename_cached (destination), 0) != -1)
- ret_was_supported = TRUE;
- else if (link (gs_file_get_path_cached (source), gs_file_get_path_cached (destination)) != -1)
+ if (linkat (-1, gs_file_get_path_cached (source), dirfd, name, 0) != -1)
ret_was_supported = TRUE;
else if (errno == EMLINK || errno == EXDEV || errno == EPERM)
{
*
* So we can't make this atomic.
*/
- (void) unlink (gs_file_get_path_cached (destination));
+ (void) unlinkat (dirfd, name, 0);
goto again;
ret_was_supported = TRUE;
}
checkout_one_file (OstreeRepo *repo,
GFile *source,
GFileInfo *source_info,
+ int destination_dfd,
+ const char *destination_name,
GFile *destination,
OstreeRepoCheckoutMode mode,
OstreeRepoCheckoutOverwriteMode overwrite_mode,
/* If we found one, try hardlinking */
if (!checkout_file_hardlink (repo, mode,
overwrite_mode, loose_path,
- destination, -1,
+ destination_dfd, destination_name,
&hardlink_supported, cancellable, error))
{
g_prefix_error (error, "Hardlinking loose object %s to %s: ", checksum,
gboolean ret = FALSE;
gs_unref_variant GVariant *xattrs = NULL;
gs_unref_object GFileEnumerator *dir_enum = NULL;
+ int destination_dfd = -1;
if (!ostree_repo_file_get_xattrs (source, &xattrs, NULL, error))
goto out;
if (!dir_enum)
goto out;
+ if (!gs_file_open_dir_fd (destination, &destination_dfd,
+ cancellable, error))
+ goto out;
+
while (TRUE)
{
GFileInfo *file_info;
}
else
{
- if (!checkout_one_file (self, src_child, file_info, dest_path,
+ if (!checkout_one_file (self, src_child, file_info,
+ destination_dfd,
+ name,
+ dest_path,
mode, overwrite_mode,
cancellable, error))
goto out;
ret = TRUE;
out:
+ if (destination_dfd != -1)
+ (void) close (destination_dfd);
return ret;
}